/**
 * 
 */
package jmath.function;

import jmath.function.meta.*;
import jmath.function.meta.Dot;
import jmath.function.meta.Volume;
import jmath.io.JMathConsole;
import jmath.io.JMathGraphPloter;


/**
 * @author timon.
 * 
 */
public abstract class VolumedModel implements Model{
	
	protected Volume volume;
	
	public void halfVolume(){
		volume.half();
	}
	
	public void showResult(JMathConsole jMathConsole,JMathGraphPloter jMathGraphPloter,String graphName) {
		Dot minValueDot=volume.getMinValueDot();
		jMathConsole.clear();
		jMathConsole.writeln("-"+volume.getDotList().size()+"-");
		for (String paramName : minValueDot.getParamValueMap().keySet()) {
			Interval interval =volume.getParamInterval(paramName);
			jMathConsole.writeln(paramName + " -    "
					+ minValueDot.getParamValueMap().get(paramName)+(interval!=null?" -    "+interval:""));			
		}
		jMathConsole.writeln("difference -   "+minValueDot.getResultValue());		
		jMathGraphPloter.clear(graphName);
		if(jMathGraphPloter.isRangeAxisIsLog()){
			jMathGraphPloter.semilogy(minValueDot.getXData(),minValueDot.getYData(),graphName);
		}else{
			jMathGraphPloter.plot(minValueDot.getXData(),minValueDot.getYData(),graphName);
		}
	}

	public Volume getVolume() {
		return volume;
	}
	
}

